unable to connect to datadase....

unable to connect to datadase....

am 21.03.2006 07:24:29 von manashi chakraborty

This is a multipart mime message


--Next_1142922268---0-203.199.83.246-7692
Content-type: text/plain;
charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

=0Ahi...=0A I am doin my project in PHP with PostgreSQL as backend...=
=0A Both r very new to me....=0AMy OS is LINUX =0A I am trying to=
connect to the database bt its not getin connected...=0A By using=0A =
"su postgres" command=0A i hav created user "root" and database "sample"=
=0A By using=0A "psql -U root sample" command=0A i hav created =
table "login" and inserted 3 data's...=0A Now through code using PHP i am=
trying to insert the data but connection is not getin established.. =0A=
the code to connect to the datadase is :-=0A =0A e "DB.php";=0A $uname=3D$_POST['uname'];=0A $pass=3D$_POST['pass'];=0A=
=0A$username=3D"root";=0A$password=3D"";=0A$hostname=3D"loca lhost";=0A$dbna=
me=3D"sample"; $db=3Dnew DB;=0A$dsource=3D$db->factory("pgsql"); =
$dcon=3Dpg_connect("dbname=3Dsample user=3Dmanashi"); $sql=3D"insert i=
nto login values('$uname','$pass')"; $rs=3D$dsource->pg_query($sq l);=
=0A?> is there anythin wrong with tthe code or sum other problem=0A =
waiting for the reply...=20
--Next_1142922268---0-203.199.83.246-7692
Content-type: text/html;
charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

=0A 
=0Ahi...
=0A    I am doin my project in PHP w=
ith PostgreSQL as backend...
=0A        Both r very=
new to me....
=0AMy OS is LINUX 
=0A I am trying to connect t=
o the database bt its not getin connected...
=0A  By using
=0A&n=
bsp;   "su postgres" command
=0A  i hav created us=
er "root" and database "sample"
=0A    By =
using
=0A    "psql -U root sample" command
=0A&n=
bsp;     i hav created table "login" and inserted 3 dat=
a's...
=0A  Now through code using PHP i am trying to insert the d=
ata but  connection is not getin established.. 
=0A  t=
he code to connect to the datadase is :-
=0A 
=0A<?php
=
=0A  require_once "DB.php";
=0A  $uname=3D$_POST['=
uname'];
=0A  $pass=3D$_POST['pass'];
=0A
=0A$username=3D&qu=
ot;root";
=0A$password=3D"";
=0A$hostname=3D"loca=
lhost";
=0A$dbname=3D"sample";
=0A
=0A$db=3Dnew DB;=

=0A$dsource=3D$db->factory("pgsql");
=0A
=0A$dcon=3D=
pg_connect("dbname=3Dsample user=3Dmanashi");
=0A
=0A$sql=
=3D"insert into login values('$uname','$pass')";
=0A
=0A$rs=
=3D$dsource->pg_query($sql);
=0A?>
=0A
=0A  is there an=
ythin wrong with tthe code or sum other problem
=0A    waiting=
for the reply... =0A

=0A

=0A /cgi-bin/AdWorks/sigclick.cgi/www.rediff.com/signature-home. htm/1507191490@=
Middle5?PARTNER=3D3"> sigimpress.cgi/www.rediff.com/signature-home.htm/1963059423@ Middle5?OAS_que=
ry=3Dnull&PARTNER=3D3" BORDER=3D0 VSPACE=3D0 HSPACE=3D0>
=0A
--Next_1142922268---0-203.199.83.246-7692--

Re: unable to connect to datadase....

am 21.03.2006 07:44:40 von Chris

manashi chakraborty wrote:
>
> hi...
> I am doin my project in PHP with PostgreSQL as backend...
> Both r very new to me....
> My OS is LINUX
> I am trying to connect to the database bt its not getin connected...
> By using
> "su postgres" command
> i hav created user "root" and database "sample"
> By using
> "psql -U root sample" command
> i hav created table "login" and inserted 3 data's...
> Now through code using PHP i am trying to insert the data but
> connection is not getin established..
> the code to connect to the datadase is :-
>
> > require_once "DB.php";
> $uname=$_POST['uname'];
> $pass=$_POST['pass'];
>
> $username="root";
> $password="";
> $hostname="localhost";
> $dbname="sample";
>
> $db=new DB;
> $dsource=$db->factory("pgsql");
>
> $dcon=pg_connect("dbname=sample user=manashi");


Add this after the pg_connect line:

echo pg_last_error();

what does that say?

Also change your mail program to send TEXT emails.

--
Postgresql & php tutorials
http://www.designmagick.com/

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly